package com.plian.system.dao.pm.propertychange;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.dto.pm.property.PropertyChangeDTO;
import com.plian.system.model.page.Page;
import com.plian.system.vo.pm.property.EconomicBehaviorCountVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PropertyChangeDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 新增
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("PropertyChangeMapper.save",pd);
    }

    /**
     * 修改
     * @param pd
     * @throws Exception
     */
    public void edit(PageData pd) throws Exception {
        dao.update("PropertyChangeMapper.edit",pd);
    }

    /**
     * * 根据Id获取一条数据
     * @param id
     * @return
     * @throws Exception
     */
    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("PropertyChangeMapper.findbyid",id);
    }

    /**
     * 获取在途的列表
     * @param pageData
     * @return
     * @throws Exception
     */
    public List<PageData> findByWayName(PageData pageData) throws Exception {
        return (List<PageData>) dao.findForObject("PropertyChangeMapper.findByWayName",pageData);
    }
    /**
     * 根据更新时间查询最新的一条数据
     * @return
     * @throws Exception
     */
    public List<PageData> listPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyChangeMapper.listPage",page);
    }


    public void del_ids(List<String> ids) throws Exception {
        dao.delete("PropertyChangeMapper.del_ids",ids);
    }

    /**
     * 修改状态
     * @param pd
     */
    public void  refer(PageData pd) throws Exception {
        dao.update("PropertyChangeMapper.refer",pd);
    }
    public void  editApprovalDate(PageData pd) throws Exception {
        dao.update("PropertyChangeMapper.editApprovalDate",pd);
    }
    /**
     * 修改状态
     * @param pd
     */
    public List<PageData> findByIds(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyChangeMapper.findByIds",pd);
    }
    /**
     * 根据多单位查询列表
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> reportListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyChangeMapper.reportListPage",page);
    }

    /**
     * 根据初始id查询记录
     * @param initialId
     * @return
     */
    public List<PageData> record(String initialId) throws Exception {
        return (List<PageData>) dao.findForList("PropertyChangeMapper.record",initialId);
    }

    public List<EconomicBehaviorCountVO> changeReasonCount(PropertyChangeDTO propertyChangeDTO) throws Exception {
        return (List<EconomicBehaviorCountVO>) dao.findForList("PropertyChangeMapper.changeReasonCount",propertyChangeDTO);
    }

    public void updateOrgCode(List<PageData> list) throws Exception {
        dao.batchSave("PropertyChangeMapper.updateOrgCode",list);
    }

    public List<PageData> allList() throws Exception {
        return (List<PageData>) dao.findForList("PropertyChangeMapper.allList",null);
    }
    public List<PageData> listByOrgCodeOrName(PageData pd) throws Exception{
        return (List<PageData>)dao.findForList("PropertyChangeMapper.listByOrgCodeOrName",pd);
    }

    public void editByOrgIdAll(List<PageData> list) throws Exception {
        dao.update("PropertyChangeMapper.editByOrgIdAll",list);
    }
}
